//
//  WKMapManager.swift
//  NewDelivery
//
//  Created by 天下宅 on 2016/11/15.
//  Copyright © 2016年 天下宅. All rights reserved.
//

import UIKit
import SwiftyJSON


class WKMapManager: NSObject,BMKLocationServiceDelegate {
    static let shard:WKMapManager = {
        let map = WKMapManager()
        map.mapManagerLoad()
        return map
    }()
    
    let locService:BMKLocationService = {
        let loc = BMKLocationService()
        return loc
    }()
    
    private func mapManagerLoad()
    {
        self.locService.delegate = self
        self.locService.pausesLocationUpdatesAutomatically = false
//        self.locService.allowsBackgroundLocationUpdates = true
        self.locService.distanceFilter = 100
    }

    func startLoction()
    {
        print("开始定位")

        self.locService.startUserLocationService()
    }
    func stopLoction()
    {
        self.locService.stopUserLocationService()
    }
    
    func didUpdate(_ userLocation: BMKUserLocation!) {
        NetWorkingManager.updateLocation(userLocation.location.coordinate, block: {(state, data) in
            
            print("定位结果")
            print(data)
//            switch state
//            {
//            case .Faild(let msg):
//                self.view.wkMakeToastToCenter(message: msg)
//            case .Success:
//                
//            }
        })
    }
}
